package com.yy.studyspringboot.queue;


import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class Order implements Delayed {
    private Long time;
    private String name;

    public Order(Long time, String name) {
        this.time = System.currentTimeMillis() + time;
        this.name = name;
    }

    @Override
    public long getDelay(TimeUnit unit) {
        return unit.convert(time - System.currentTimeMillis(), unit);
    }

    @Override
    public int compareTo(Delayed o) {
        return 0;
    }

    @Override
    public String toString() {
        return "Order{" +
                "time=" + time +
                ", name='" + name + '\'' +
                '}';
    }
}
